#ifndef CHAIN_H 
#define CHAIN_H

#include "parsing\chainparser.h"
#include "Vertex.h"
#include "Graph.h"
#include "vertexDirectory.h"
#include "Group.h"
#include "Input.h"

// Defines for the Compare method
#define BIGGER 1
#define SMALLER -1
#define EQUAL 0

class Chain
{
public:
	Chain(ChainParser &permutationsFile, InputVariables inputVariables);
	Chain(Graph *graph, VertexDirectory *dir);

	set<int> ChainGroupNames();
	list<Group*> ChainGroups();
	Group* GetGroup(int groupId);
	void AddGroup(Group *group);
	~Chain();
	Graph* GetGraph();
	VertexDirectory *GetDirectory();
	list<Group*>::iterator Begin();
	list<Group*>::iterator NonPermutationsGroupsBegin();
	list<Group*>::iterator End();
	Chain *CloneFromVertexDirectoryAndUpdateIt(VertexDirectory *directory);
	int GetNextGroupIndex();
	int GetLength();
	int Compare(Chain* otherChain);
	int Compare(int* chainGroupSizes, int arrayLen);
	int CompareSubChains(Chain* otherChain, int length);
	void PrintGroupData();
	int GetMaxGroupIndex();
	void Print();
	void SetLastGroupFromPermutaionsIndex(int index);
	int  GetLastGroupFromPermutaionsIndex();


private:
	void CreateGroups(ChainParser &chainFile);
	map<vector<bool>, Vertex*>* MakeDirectoryPointerMap();

	Graph*				m_Graph;
	list<Group*>		m_Groups;
	set<int>			m_GroupNames;
	int					m_Length;
	VertexDirectory*	m_VertexDirectory;
	int					m_LastGroupFromPermutaionsIndex; //first index is 0
	
};


#endif //CHAIN_H
